/**
 * use WebSocket protocol deployed contracts
 * add by: martin
 * date:2018-06-30
 */
/*********************************use WebSocket protocol deployed contracts ************************/
// const Web3 = require('web3');
// let web3 = new Web3(new Web3.providers.WebsocketProvider('ws://localhost:8546'))

// const MyContractJSON = JSON.parse(require('fs').readFileSync('./build/contracts/Token.json', 'utf8'));
// console.log('MyContract', MyContractJSON)

// const myContractIns = new web3.eth.Contract(
//   MyContractJSON.abi,
//   // MyContract.networks[MY_NETWORK_ID].address,
//   // {from: MY_COINBASE, gas: MY_DEFAULT_GAS, gasPrice: MY_DEFAULT_GAS_PRICE}
// )
// const mySenderAddress = '0x36215Da2830dE0063e3f6B42a66a21084426cC17';

// web3.eth.estimateGas({ data: MyContractJSON.bytecode, gas: 9999999999,from: mySenderAddress, }).then((gasLimit) => {
//   console.log('estimateGas:', gasLimit);
//   deploy(gasLimit);
// })

// let deploy = (gasLimit) => {
//   //deploy contracts
//   myContractIns.deploy({
//     data: MyContractJSON.bytecode,
//     arguments: []
//   }).send({
//     from: mySenderAddress,
//     nonce: gasLimit,
//     gasPrice: '0',
//     gas: gasLimit,
//   }, (error, transactionHash) => {
//     console.log('transactionHash=>', transactionHash)
//   })
//     .on('error', function (error) {
//       console.log('error:==>', error)
//     })
//     .on('transactionHash', (transactionHash) => {
//       web3.eth.getTransaction(transactionHash).then(tx=>console.log(tx))
//     })// contains the transactionHash
//     .on('receipt', function (receipt) {
//       console.log('contractAddress:=>', receipt.contractAddress) // contains the new contract address
//     })
//     .on('confirmation', function (confirmationNumber, receipt) {
//       console.log('confirmationNumber:=>',confirmationNumber)
//     })
//     .then((newContractInstance) => {
//       console.log(newContractInstance.options.address) // instance with the new contract address
//     });
// }
/*********************************use WebSocket protocol deployed contracts **************0x769022D634248eDA04a7d81C94d20d4e67E37dDB**********/







module.exports = {
  // See <http://truffleframework.com/docs/advanced/configuration>
  // for more about customizing your Truffle configuration!
  networks: {
    development: {
      host: "192.168.2.155",
      port: 8546,
      gas:1511053,
      gasPrice:0,
      network_id: "*"// Match any network id
      // provider - web3 provider instance Truffle should use to talk to the Ethereum network.
      //          - function that returns a web3 provider instance (see below.)
      //          - if specified, host and port are ignored.
    }
  }
};
